package com.tju.resource.business.tb_pur_store.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tju.resource.business.tb_pur_store.TbPurStoreService;
import com.tju.resource.mapper.TbPurStoreMapper;
import com.tju.resource.model.TbPurStore;
import com.tju.resource.result.Result;
import com.tju.resource.result.ResultEnum;
import com.tju.resource.result.ResultUtil;
import com.tju.resource.tool.tool.EmptyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
/**
 * 耗材入库记录
 */
@Service
public class TbPurStoreServiceImpl extends ServiceImpl<TbPurStoreMapper, TbPurStore>
implements TbPurStoreService {
    @Autowired
    private TbPurStoreMapper tbPurStoreMapper;
    /**
     * 查询耗材入库记录
     * @param params
     * @return
     */
    @Override
    public Result<Object> selectTbPurStore(Map<String, String> params) {
        if (EmptyUtils.isNotEmpty(params.get("page")) && EmptyUtils.isNotEmpty(params.get("limit"))) {
            Page<TbPurStore> page = new Page<>(Long.parseLong(params.get("page")), Long.parseLong(params.get("limit")));
            IPage<TbPurStore> iPage = tbPurStoreMapper.selectTbPurStore(page, params);
            List<TbPurStore> records = iPage.getRecords(); //发料记录
            return ResultUtil.success(ResultEnum.SUCCESS, records, records.size());
        }
        return ResultUtil.error(ResultEnum.UNKONW_ERROR, "缺少参数!");
    }
}




